#include "UpdatePreviewNetworkEvent.h"

UpdatePreviewNetworkEvent::UpdatePreviewNetworkEvent(Positions positions, Color color)
{
    message.header.code = NetworkEvent::SERVER_UPDATE_PREVIEW;
    message.header.sizeOfData = sizeof(message) - sizeof(message.header);

    for (int i = 0; i < 4; ++i)
    {
        message.data.positions[i] = positions[i];
    }
    message.data.color = color;
}

UpdatePreviewNetworkEvent::UpdatePreviewNetworkEvent(const Header& header, const Data& data)
{
    message.header = header;
    message.data = data;
}
UpdatePreviewNetworkEvent::~UpdatePreviewNetworkEvent()
{
}

void* UpdatePreviewNetworkEvent::getMessageBlob()
{
    return &message;
}

size_t UpdatePreviewNetworkEvent::getMessageBlobSize()
{
    return sizeof(message);
}

void UpdatePreviewNetworkEvent::visitPiecePreview(PiecePreview* piecePreview) const
{
    piecePreview->handlePreviewUpdate(message.data.positions, message.data.color);
}
